@layout("/common/_container.html"){

<div class="row">
    <div class="col-sm-12">
    	<div class="row border-bottom white-bg">
            <nav class="navbar navbar-static-top" role="navigation">
                <div class="navbar-header">
                    <button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
                        <i class="fa fa-reorder"></i>
                    </button>
                    <a href="#" class="navbar-brand">信息发布平台</a>
                </div>
                <div class="navbar-collapse collapse" id="navbar">
                    <ul class="nav navbar-nav">
                        <li class="">
                            <a type="button"  aria-expanded="false" role="button" href="#" onclick="openAdd()">
                               	 <i class="fa fa-plus i-green">发布货源</i> </a>
                        </li>
                        <li class="">
                            <a type="button"  aria-expanded="false" role="button" href="#" onclick="openCarAdd()">
                               	 <i class="fa fa-plus i-green">发布车源 </i></a>
                        </li>

                    </ul>
                </div>
            </nav>
        </div>

        <div class="col-lg-12">
	        <div class="ibox float-e-margins">
	            <div class="ibox-title">
	                <h5>货源信息</h5>
	                <div class="top-btn-div">
	                	<!-- <button type="button" onclick="preSearch();vm.loadData()" id="" class="btn btn-info  btn-outline btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>&nbsp; -->
	                	
	                	<button type="button" onclick="openAdd()" id="" class="btn btn-info btn-outline btn-sm"><i class="fa fa-plus"></i>&nbsp;发布货源</button>&nbsp;
	                </div>
	            </div>
	            <div class="ibox-content" id="PlatformTable">
	            	<div class="table-responsive">
                        <v-table
                        	:is-loading="isLoading"
			              	is-vertical-resize
			              	:vertical-resize-offset='60'
			              	is-horizontal-resize
			              	style="width:100%"
			              	:multiple-sort="false"
			              	:min-height="350"
			              	even-bg-color="#fafafa"
			              	:columns="columns"
			              	:table-data="tableData"
			              	row-hover-color="#edf7ff"
			              	row-click-color="#edf7ff"
			              	:paging-index="(pageIndex-1)*pageSize">
				        </v-table>
				        <v-pagination v-on:page-change="pageChange" v-on:page-size-change="pageSizeChange" :total="total" :page-index="pageIndex" :page-size="pageSize" :layout="['total', 'prev', 'pager', 'next', 'sizer', 'jumper']"></v-pagination>
                    </div>
                </div>
            </div>
        </div>
        
<script>
	var selectIndex = 0;
	var selectObject = {};
	var defaultColunms=[

	    {field: 'waybillNum', title:'运单号', width: 150, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'shipper', title: '发货人名称', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'shipperPhone', title: '发货人电话', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'origin', title: '发货地址', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'originProvince', title:'发货省市区', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'consignee', title: '收货人名称', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'consigneePhone', title: '收货人电话', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'destination', title: '目的地', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'destinationProvince', title:'收货省市区', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'cargo', title: '货物', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'number', title: '数量', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'weight', title: '重量', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'volume', title: '体积', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true}
		
	];
	Vue.component('table-operation',{
		template:`<span>
		
		<a href="/platform/update" v-on:click.stop.prevent="update(rowData,index)" title="编辑" class="a-hover"><i class="fa fa-search i-green"></i> </a>
        <a href="/platform/delete" v-on:click.stop.prevent="deleteRow(rowData,index)" title="删除" class="a-hover"><i class="fa fa-trash-o i-red"></i> </a>
		</span>`,
		props:{
		    rowData:{
		        type:Object
		    },
		    field:{
		        type:String
		    },
		    index:{
		        type:Number
		    }
		},
		methods:{
			update(){
                // 参数根据业务场景随意构造
                var params = {type:'edit',index:this.index,rowData:this.rowData};
                console.info(params.index);
                selectIndex=params.index
                var index = layer.open({
                    type: 2,
                    title: '管理详情',
                    area: ['800px', '700px'], //宽高
                    fix: false, //不固定
                    maxmin: true,
                    content: Feng.ctxPath + '/platform/update?id=' + params.rowData.id
                });
                //this.layerIndex = index;
            },
            deleteRow(){
            	var params = {type:'edit',index:this.index,rowData:this.rowData};
            	layer.confirm('确定要删除？', {
          			btn: ['确认','取消'] //按钮
          		}, 
          		function(){
          			index = layer.load(2);
          	    	$.ajax({
          	    		url:"/platform/delete?id="+params.rowData.id,
          	    		type:"get",
          	    		success:function(data){
          	    			vm.tableData.splice(params.index,1)
          	    			layer.close(index);
          	    			layer.msg("删除成功！");
          	    		},
          	    		error:function(){
          	    			layer.close(index);
          	    			layer.alert("删除失败！");
          	    		}
          	    	});
          		}, 
          		function(){
          		});
            }
		}
	})
	function openAdd(){
        var index = layer.open({
            type: 2,
            title: '发布货源',
            area: ['800px', '700px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/platform/add'
        });
	}
	
	var vm = new ESTable("PlatformTable", "/platform/list", defaultColunms);
	
	function preSearch(){
		vm.pageChange(1);
		vm.queryParam.beginCreatetime=$("#begintime").val()
	}
</script>
        
        
        <div class="col-lg-12">
	        <div class="ibox float-e-margins">
	            <div class="ibox-title">
	                <h5>车源信息</h5>
	                <div class="top-btn-div">
	                	<!-- <button type="button" onclick="preSearch();vm.loadData()" id="" class="btn btn-info  btn-outline btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>&nbsp; -->
	                	
	                	<button type="button" onclick="openCarAdd()" id="" class="btn btn-info btn-outline btn-sm"><i class="fa fa-plus"></i>&nbsp;发布车源</button>&nbsp;
	                </div>
	            </div>
	            <div class="ibox-content" id="PtcarTable">
	            	<div class="table-responsive">
                        <v-table
                        	:is-loading="isLoading"
			              	is-vertical-resize
			              	:vertical-resize-offset='60'
			              	is-horizontal-resize
			              	style="width:100%"
			              	:multiple-sort="false"
			              	:min-height="350"
			              	even-bg-color="#fafafa"
			              	:columns="columns"
			              	:table-data="tableData"
			              	row-hover-color="#edf7ff"
			              	row-click-color="#edf7ff"
			              	:paging-index="(pageIndex-1)*pageSize">
				        </v-table>
				        <v-pagination v-on:page-change="pageChange" v-on:page-size-change="pageSizeChange" :total="total" :page-index="pageIndex" :page-size="pageSize" :layout="['total', 'prev', 'pager', 'next', 'sizer', 'jumper']"></v-pagination>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>




<!-- 车源 -->
<script>
	var carselectIndex = 0;
	var carselectObject = {};
	var ptcarColunms=[

	    {field: 'carNum', title:'车牌号', width: 150, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'owner', title: '车主姓名', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'ownerPhone', title: '车主电话', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'enterTime', title: '录入时间', width: 100, titleAlign: 'center',columnAlign:'center',isResize:true}, 
	    {field: 'useable', title:'是否可用', width: 50, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'carType', title: '车辆类型', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'length', title: '车长', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'wide', title: '车宽', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'high', title:'车高', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true},
	    {field: 'limitWeigh', title: '限载（吨）', width: 80, titleAlign: 'center',columnAlign:'center',isResize:true}
		
	];
	Vue.component('cartable-operation',{
		template:`<span>
		
		<a href="/ptcar/update" v-on:click.stop.prevent="carupdate(rowData,index)" title="编辑" class="a-hover"><i class="fa fa-search i-green"></i> </a>
        <a href="/ptcar/delete" v-on:click.stop.prevent="cardeleteRow(rowData,index)" title="删除" class="a-hover"><i class="fa fa-trash-o i-red"></i> </a>
		</span>`,
		props:{
		    rowData:{
		        type:Object
		    },
		    field:{
		        type:String
		    },
		    index:{
		        type:Number
		    }
		},
		methods:{
			carupdate(){
                // 参数根据业务场景随意构造
                var params = {type:'edit',index:this.index,rowData:this.rowData};
                console.info(params.index);
                carselectIndex=params.index
                var index = layer.open({
                    type: 2,
                    title: '管理详情',
                    area: ['800px', '600px'], //宽高
                    fix: false, //不固定
                    maxmin: true,
                    content: Feng.ctxPath + '/ptcar/update?id=' + params.rowData.id
                });
                //this.layerIndex = index;
            },
            cardeleteRow(){
            	var params = {type:'edit',index:this.index,rowData:this.rowData};
            	layer.confirm('确定要删除？', {
          			btn: ['确认','取消'] //按钮
          		}, 
          		function(){
          			index = layer.load(2);
          	    	$.ajax({
          	    		url:"/ptcar/delete?id="+params.rowData.id,
          	    		type:"GET",
          	    		success:function(data){
          	    			mv.tableData.splice(params.index,1)
          	    			layer.close(index);
          	    			layer.msg("删除成功！");
          	    		},
          	    		error:function(){
          	    			layer.close(index);
          	    			layer.alert("删除失败！");
          	    		}
          	    	});
          		}, 
          		function(){
          		});
            }
		}
	})
	function openCarAdd(){
        var index = layer.open({
            type: 2,
            title: '发布车源',
            area: ['800px', '600px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/ptcar/add'
        });
	}
	
	var mv = new ESTable("PtcarTable", "/ptcar/list", ptcarColunms);
	
	function preSearch(){
		mv.pageChange(1);
		mv.queryParam.beginCreatetime=$("#begintime").val()
	}
</script>
@}


